﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Web_PGCX : System.Web.UI.Page
{
    
    private string cp = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        
        cp = Request.QueryString["Pinzhong"];
        ShowList(cp);
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        ShowList(cp);
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string num;
            string pinzhong;
            string guige;
            num = (string)((DataRowView)e.Row.DataItem).Row.ItemArray[0];
            pinzhong = (string)((DataRowView)e.Row.DataItem).Row.ItemArray[1];
            guige = (string)((DataRowView)e.Row.DataItem).Row.ItemArray[2];

            //when mouse over
            e.Row.Attributes.Add("onmouseover", "this.className='GridView_onmouseover';");
            //when mouse out
            e.Row.Attributes.Add("onmouseout", "this.className='GridView_onmouseout';");
            //将光标设为手形
            e.Row.Attributes.Add("style", "cursor: hand;");
            //行链接
            switch (cp)
            {
                case "线材":
                    e.Row.Attributes.Add("onclick", "window.location='XKCDT.aspx?Pinzhong=" + pinzhong + "&Guige=" + guige + "&Num=" + num + "'"); break;
                case "棒材":
                    e.Row.Attributes.Add("onclick", "window.location='BKCDT.aspx?Pinzhong=" + pinzhong + "&Guige=" + guige + "&Num=" + num + "'"); break;
                case "酸洗热轧":
                    e.Row.Attributes.Add("onclick", "window.location='RKCDT.aspx?Pinzhong=" + pinzhong + "&Guige=" + guige + "&Num=" + num + "'"); break;
                case "冷轧":
                    e.Row.Attributes.Add("onclick", "window.location='LKCDT.aspx?Pinzhong=" + pinzhong + "&Guige=" + guige + "&Num=" + num + "'"); break;
                case "中板":
                    e.Row.Attributes.Add("onclick", "window.location='ZKCDT.aspx?Pinzhong=" + pinzhong + "&Guige=" + guige + "&Num=" + num + "'"); break;
                default:
                    break;
            }
            


        }
    }
    private void ShowList(string pinzhong)
    {
        DataSet ds = null;
        switch (pinzhong)
        {
            case "线材":
                ds = BLLFactory.CreateXkcdtBLL().SelectPG(Session["用户信息.部门"].ToString()); break;
            case "棒材":
                ds = BLLFactory.CreateBkcdtBLL().SelectPG(Session["用户信息.部门"].ToString()); break;
            case "酸洗热轧":
                ds = BLLFactory.CreateRkcdtBLL().SelectPG(Session["用户信息.部门"].ToString()); break;
            case "冷轧":
                ds = BLLFactory.CreateLkcdtBLL().SelectPG(Session["用户信息.部门"].ToString()); break;
            case "中板":
                ds = BLLFactory.CreateZkcdtBLL().SelectPG(); break;
            default:
                break;
        }
        if (ds != null)
        {
            GridView1.DataSource = ds.Tables[0];
        }
        else
        {
            GridView1.DataSource = null;
        }
        GridView1.DataBind();
    }
}
